package org.dyz.banana.platform.common.controller;


import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.dyz.banana.platform.common.service.ITRoleService;
import org.dyz.banana.platform.common.vo.HttpResult;
import org.dyz.banana.platform.common.vo.TRoleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

/**
 * <p>
 * 角色 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-01-06
 */
@RestController
@RequestMapping("/common/tRole")
public class TRoleController {
	@Autowired
	ITRoleService tRoleService;
	
	
	public void settRoleService(ITRoleService tRoleService) {
		this.tRoleService = tRoleService;
	}


	@GetMapping(value = "/getByUsername")
	public HttpResult getByUsername(String username, HttpServletRequest request){
		List<TRoleVo> roleVos = tRoleService.getRoleByUsername(username);
		return HttpResult.ok(roleVos);
	}
	
	@GetMapping(value = "/getAll")
	public HttpResult getAll(HttpServletRequest request){
		QueryWrapper<TRoleVo> queryWrapper = new QueryWrapper<TRoleVo>();
		queryWrapper.eq("defunInd", "0");
		List<TRoleVo> roleVos = tRoleService.list(queryWrapper);
		return HttpResult.ok(roleVos);
	}
}

